package com.csxy.news.dao;

import java.util.Map;

import com.csxy.news.bean.User;
import com.csxy.news.util.JdbcUtil;

/**
 * 数据访问层：用户访问，只与数据库操作有关，和业务逻辑无关
 * @author Administrator
 *
 */
public class UserDao {

	/**
	 * 根据名称，获取用户对象
	 * @param username
	 * @return
	 */
	public User findOneByName(String username) {
		
		StringBuffer sb=new StringBuffer();
		sb.append("select * from `user` where `name`=? ");
		try {
			JdbcUtil.openConnection();
			Map<String, Object> row=JdbcUtil.selectOne(sb.toString(), username);
			if(row.size()>0){
				User u=JdbcUtil.mapToBean(User.class, row);
				
				return u;
			}
		} catch (Exception e) {

		} finally {
			JdbcUtil.closeConnection();
		}
		
		return null;
	}
   
}
